<template>
  <header class="animate__animated animate__fadeInDown">
    <el-input v-model="search" @input="setKeyword" size="large" placeholder="搜索" :prefix-icon="Search" />
    <div class="user">
      <el-button type="default" @click="setNotice">
        <span class="iconfont icon-xiaoxi3"></span>
      </el-button>
      <div class="right flex-jucalic">
        <img src="@/assets/vue.svg" alt="avatar" />
        <span class="username">金金设计素材</span>
        <span class="iconfont icon-xiala"></span>
      </div>
    </div>
  </header>
</template>

<script setup lang="ts">
import { Search } from '@element-plus/icons-vue';
import { ref, inject, Ref } from 'vue';

const showNotice = inject<Ref<boolean>>("showNotice")!

defineProps<{ keyword: string }>()
const emits = defineEmits(["update:keyword"])


const search = ref("")

function setKeyword() {
  emits("update:keyword", search.value)
}

function setNotice() {
  showNotice.value = true;
}


</script>

<style lang="scss" scoped>
header {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;

  .el-input {
    width: 300px;
    border: 0px;
  }

  .user {
    display: flex;
    justify-content: center;
    align-items: center;

    .el-button {
      width: 40px;
      height: 40px;
      padding: 0;

      .iconfont {
        font-size: 24px;
      }

    }

    .right {
      background-color: white;
      padding: 6px 10px 6px 10px;
      margin-left: 20px;
      border-radius: 6px;
      gap: 10px;


      >img {
        width: 20px;
        height: 20px;
        border-radius: 50%;
      }
    }
  }
}
</style>